<template>
    <el-container class="wx_setting_container">
        <el-main>
            <el-card class="box-card">
                <template v-for="(item, index) in settingList">
                    <div class="setting_item" :key="index">
                        <el-divider content-position="left" class="title">{{ item.title }}</el-divider>
                        <setting-form :type="item.code" :rules="item.rules" :fields="item.fields"
                                      :label-width="item.labelWidth" :key="item.code" />
                    </div>
                </template>
            </el-card>
        </el-main>
    </el-container>
</template>

<script>
import SettingForm from "../common/SettingForm";
import setting from "#/setting";

export default {
    name: "CmsSetting",
    components: { SettingForm },
    data() {
        return {
            rules: {},
            fields: [
                {
                    label: '应用名称',
                    prop: 'wx_open_name',
                    type: 'text',
                },
                {
                    label: '应用AppId',
                    prop: 'wx_open_appid',
                    type: 'text',
                },
                {
                    label: '应用AppSecret',
                    prop: 'wx_open_app_secret',
                    type: 'text',
                },
                {
                    label: '微信扫码成功回调地址',
                    prop: 'wx_open_callback_url',
                    type: 'text',
                },
                {
                    label: '微信扫码成功跳转地址',
                    prop: 'wx_open_redirect_url',
                    type: 'text',
                },
            ],
            mpRules: {},
            mpFields: [
                {
                    label: '公众号名称',
                    prop: 'wechat_name',
                    type: 'text',
                },
                {
                    label: '公众号原始Id',
                    prop: 'wechat_gzh',
                    type: 'text',
                },
                {
                    label: '公众号AppId',
                    prop: 'wechat_app_id',
                    type: 'text',
                },
                {
                    label: '公众号AppSecret',
                    prop: 'wechat_app_secret',
                    type: 'text',
                },
                {
                    label: '公众号Token',
                    prop: 'wechat_token',
                    type: 'text',
                },
                {
                    label: '公众号EncodingAESKey',
                    prop: 'wechat_encoding_aes_key',
                    type: 'text',
                },
            ],
            miniappRules: {},
            miniappFields: [
                {
                    label: '小程序名称',
                    prop: 'miniapp_name',
                    type: 'text',
                },
                {
                    label: '小程序AppId',
                    prop: 'miniapp_app_id',
                    type: 'text',
                },
                {
                    label: '小程序AppSecret',
                    prop: 'miniapp_app_secret',
                    type: 'text',
                },
            ],
            wxPayRules: {},
            wxPayFields: [
                {
                    label: '微信支付appid',
                    prop: 'wxpay_app_id',
                    type: 'text',
                },
                {
                    label: '微信支付appsecret',
                    prop: 'wxpay_app_secret',
                    type: 'text',
                },
                {
                    label: '微信支付商户kid',
                    prop: 'wxpay_mch_id',
                    type: 'text',
                },
                {
                    label: '微信支付商户key',
                    prop: 'wxpay_mch_key',
                    type: 'text',
                },
                {
                    label: '微信支付完成通知接收URL',
                    prop: 'wxpay_notify_url',
                    type: 'text',
                },
                {
                    label: '微信支付证书存放路径',
                    prop: 'wxpay_key_path',
                    type: 'text',
                },
            ],
        }
    },
    computed: {
        settingList() {
            let list = [];
            list.push(setting.wx_setting.open);
            list.push(setting.wx_setting.mp);
            list.push(setting.wx_setting.miniapp);
            list.push(setting.wx_setting.pay);
            list.push(setting.wx_setting.cp);
            return list;
        },
    },
}
</script>

<style lang="less" rel="stylesheet/less" scoped>
.wx_setting_container {
    width: 100%;
    height: 100%;

    .title {

        .el-divider__text {
            font-size: 20px;
            font-weight: bold;
        }
    }
}
</style>
